package db;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by dllo on 17/4/18.
 */

public class RxSQLite {

    public static void addRecord(final RecordEntity recordEntity) {
        Observable.just(recordEntity).map(new Function<RecordEntity, RecordEntity>() {
            @Override
            public RecordEntity apply(@NonNull RecordEntity recordEntity) throws Exception {
                return new RecordEntity();
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();


    }

    public static void removeRecord(final int id) {
        Observable.just(id).map(new Function<Integer, RecordEntity>() {
            @Override
            public RecordEntity apply(@NonNull Integer integer) throws Exception {
                return new RecordEntity();
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
    }

    public static void updateRecord(RecordEntity car) {
        Observable.just(car).map(new Function<RecordEntity, RecordEntity>() {
            @Override
            public RecordEntity apply(@NonNull RecordEntity recordEntity) throws Exception {
                return new RecordEntity();
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
    }

    public static void queryRecord() {
        Observable.just("").map(new Function<String, Object>() {
            @Override
            public Object apply(@NonNull String s) throws Exception {
                return null;
            }
        }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe();
    }


}
